﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 游戏平台原型
{
    class Connection
    {
        public SqlConnection con;
        public SqlCommand com;
        public SqlDataReader dr;
        public Connection()
        {
        con = new SqlConnection();
        com = new SqlCommand();
        con.ConnectionString = "Server = (localdb)\\MSSQLLocalDB; Initial Catalog = mikotoy; Integrated Security = true";
        //con.ConnectionString = "server=127.0.0.1;database=mikotoy;uid=miko;pwd=miko";
        }
        public void sql(string CommandText)
        {
            con.Close();//关闭数据库
            con.Open();
            com.Connection = con;
            com.CommandType = CommandType.Text;
            com.CommandText = CommandText;
            //dr.Close();//关闭执行
            dr = com.ExecuteReader();//执行SQL语句
        }
    }
}
